#include <iostream>
using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	char c;
	cin >> c;
	int t = 0;
	cin >> t;
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			if(i == 1 || i == h || j == 1 || j == w)
				cout << c;
			else if(t == 0)
				cout << ' ';
			else
				cout << c;
		}
		cout << endl;
	}
	return 0;
 } 
